<?php
    require_once('../includes/DbConnector.php');
    if(isset($_GET['action']) && !empty($_GET['action'])) {
        // INPUT DATA.
        $action = $_GET['action'];
        $connector  = new DbConnector();
        $sql = "select
            h.*,
            b.name bar_name,
            p.name place,
            c.name country
            from happening h, bar b, place p, country c
            where b.postal_no = p.postal_no
            and p.country_code = c.country_code
            and h.bar_id = b.bar_id
            and curdate() < h.date
            order by h.date
            limit 10";
        $result = $connector->query($sql);
        
        $a=array();
        while($row = mysql_fetch_array($result)){
            array_push($a,$row);
        }
        echo json_encode($a);
    }
?>